// survey.entity.ts
import { BaseEntity } from "src/common/base.entity";
import { Question } from "src/modules/question/entities/question.entity";
import { Result } from "src/modules/result/entities/result.entity";
import { Column, Entity, JoinColumn, JoinTable, ManyToOne, OneToMany } from "typeorm";

@Entity({ name: 'survey', comment: '测试表' })
export class Survey extends BaseEntity {
    @Column({ type: 'varchar', length: 255, comment: '标题' })
    title: string;

    @Column({ type: 'varchar', length: 255, comment: '题目' })
    questionIds: string;

    @Column({ type: 'varchar', length: 255, comment: '结果' })
    resultIds: string;

    @Column({ type: 'int', comment: '已测人数' })
    participantsCount: number;

    @Column({ type: 'varchar', length: 255, comment: '缩略图' })
    thumbnail: string;

    @Column({ type: 'varchar', length: 255, comment: '背景图' })
    background: string;

    @OneToMany(() => Question, question => question.survey)
    // @JoinTable()
    questions: Question[];

    @OneToMany(() => Result, result => result.survey)
    // @JoinTable()
    results: Result[];

    questionNames: string[];
}
